function login() {
	var o = this;
	var rex_mobile =
		/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
	var rex_vcode = /^[0-9]+$/;
	this.mobileInitInfo = "杈撳叆11浣嶆暟鐨勬墜鏈哄彿";
	this.vcodeInitInfo = "杈撳叆6浣嶆暟鐨勯獙璇佺爜";
	this.isSubmit = 1;
	this.isLogin = 0;
	this.tabID = 0;
	this.LoginType = 1;
	this.enLoginBtn = null;
	this.TimeOutInfo = null;
	this.nc = null;
	this.init = function() {
		o.setLoginType(o.LoginType);
		return o
	};
	this.LoginTypeBtn = function(id) {
		o.enLoginBtn = null;
		o.setLoginType(id)
	};
	this.getSmsLoginCode = function(obj) {
		var clt_moblie = $("#mobile_1");
		if (o.isSubmit == 1 && clt_moblie.length > 0) {
			var m = clt_moblie.val();
			if (m.length != 11 || !rex_mobile.test(m)) {
				o.tips("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙风爜锛�11浣嶆暟锛�", clt_moblie, true)
			} else {
				if (o.nc != null) {
					o.nc.show();
					o.nc.reset()
				} else {
					var nc_token = ["FFFF0N00000000008869", (new Date()).getTime(), Math.random()].join(":");
					var NC_Opt = {
						renderTo: "#dynsendverify",
						appkey: "FFFF0N00000000008869",
						scene: "nc_message",
						token: nc_token,
						customWidth: "100%",
						trans: {
							"mobile": $("#mobile_1").val()
						},
						elementID: ["usernameID"],
						is_Opt: 0,
						language: "cn",
						isEnabled: true,
						timeout: 3000,
						times: 5,
						apimap: {},
						callback: function(data) {
							o.sendSmsCode(obj, m, nc_token, NC_Opt.scene, data.csessionid, data.sig)
						}
					};
					o.nc = new noCaptcha(NC_Opt);
					o.nc.upLang("cn", {
						_startTEXT: "璇锋寜浣忔粦鍧楋紝鎷栧姩鍒版渶鍙宠竟",
						_yesTEXT: "楠岃瘉閫氳繃",
						_error300: '鍝庡憖锛屽嚭閿欎簡锛岀偣鍑�<a href="javascript:__nc.reset()">鍒锋柊</a>鍐嶆潵涓€娆�',
						_errorNetwork: '缃戠粶涓嶇粰鍔涳紝璇�<a href="javascript:__nc.reset()">鐐瑰嚮鍒锋柊</a>',
					})
				}
			}
		}
	};
	this.sendSmsCode = function(obj, m, nc_token, Scene, csessionid, sig) {
		var btn = $(obj);
		var clt_moblie = $("#mobile_1");
		var clt_code = $("#dynpwd_1");
		var _btnOldTxt = btn.text();
		var _btnOldClick = btn.attr("onclick");
		glb.ajax("/sys/sms.ashx?t=LoginSmsCode", "JSON", "ispc=1&mobile=" + m + "&Token=" + nc_token + "&SessionId=" +
			csessionid + "&sig=" + sig + "&Scene=" + Scene,
			function() {
				o.isSubmit = 0;
				btn.attr("onclick", "").addClass("off").text("鍙戦€佷腑")
			},
			function(data) {
				var d = eval(data);
				if (d.status == 1) {
					$.jsuccess("鍙戦€佹垚鍔�", "auto", function() {
						clt_code.focus()
					}, null);
					var _time = 120;
					var _interval = null;
					btn.html("<i>" + _time + "</i>绉掑悗閲嶆柊鑾峰彇");
					var n = btn.find("i");
					n.text(_time--);
					_interval = setInterval(function() {
						n.text(_time--);
						if (_time < -1) {
							if (_interval != null) {
								clearInterval(_interval)
							}
							btn.html(_btnOldTxt);
							btn.removeClass("off");
							o.isSubmit = 1;
							o.nc.hide()
						}
					}, 1000)
				} else {
					o.nc.hide();
					btn.attr("onclick", _btnOldClick).removeClass("off").text(_btnOldTxt);
					o.isSubmit = 1;
					if (d.status == 2) {
						o.tips("鍙戦€侀鐜囧お蹇簡", clt_code, true)
					} else {
						if (d.status == 3) {
							o.tips("浠婃棩鍙戦€佺殑鐭俊楠岃瘉鏁伴噺宸茶揪涓婇檺", clt_code, true)
						} else {
							if (d.status == 4) {
								o.tips("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙�", clt_moblie, true)
							} else {
								if (d.status == 6 || d.status == 12) {
									o.tips("鎮ㄥ彂閫佸お棰戠箒浜�", clt_code, true)
								} else {
									if (d.status == 7) {
										o.tips("鎶辨瓑锛岃甯愬彿宸叉敞閿€锛�<br />鍘熷洜锛�" + d.ForbidLoginReason, clt_moblie, true)
									} else {
										if (d.status == 11) {
											o.tips("璇ユ墜鏈哄皻鏈粦瀹氳处鍙凤紝璇峰皾璇曚娇鐢ㄢ€滆处鍙峰瘑鐮佺櫥褰曗€濇柟寮忕櫥褰曚綘鐨勮处鍙�", null, true)
										} else {
											if (d.status == 900) {
												o.nc.show();
												o.nc.reset();
												o.tips("楠岃瘉澶辫触锛氳鎸変綇婊戝潡锛屾嫋鍔ㄥ埌鏈€鍙宠竟", null, true)
											} else {
												o.tips("鎿嶄綔澶辫触,璇烽噸鏂板皾璇�", null, true)
											}
										}
									}
								}
							}
						}
					}
				}
			},
			function() {
				o.nc.hide();
				btn.attr("onclick", _btnOldClick).removeClass("off").text(_btnOldTxt);
				o.isSubmit = 1;
				o.tips("鎿嶄綔澶辫触,璇烽噸鏂板皾璇�", null, true)
			})
	};
	this.setLoginType = function(typeid) {
		if (o.isLogin == 0) {
			o.LoginType = typeid;
			if (o.LoginType < 0 && o.LoginType > 2) {
				o.LoginType = 0
			}
			$("#logintype>li").show();
			$("#logintype>.loginbtn_" + o.LoginType).hide();
			$(".loginform").hide();
			$("#loginform_" + o.LoginType).fadeIn();
			$("#logoicon>b").text($("#logintype>.loginbtn_" + o.LoginType + ">a").text());
			var _btn = $("#btn_login_" + o.LoginType);
			var _mobile = $("#mobile_" + o.LoginType);
			_btn.prop("disabled", true);
			o.enLoginBtn = setInterval(function() {
				if (o.LoginType == 0) {
					if (_btn.attr("class") == "off" && _mobile.val() != "") {
						_btn.removeClass("off").prop("disabled", false)
					} else {
						if (_btn.attr("class") != "off" && _mobile.val() == "") {
							_btn.addClass("off").prop("disabled", true)
						}
					}
				} else {
					if (o.LoginType == 1) {
						var _dynpwd = $("#dynpwd_" + o.LoginType);
						if (_btn.attr("class") == "off" && _mobile.val() != "" && _dynpwd.val() != "") {
							_btn.removeClass("off").prop("disabled", false)
						} else {
							if (_btn.attr("class") != "off" && (_mobile.val() == "" || _dynpwd.val() == "")) {
								_btn.addClass("off").prop("disabled", true)
							}
						}
					} else {
						if (o.LoginType == 2) {
							var _password = $("#password_" + o.LoginType);
							if (_btn.attr("class") == "off" && _mobile.val() != "" && _password.val() != "") {
								_btn.removeClass("off").prop("disabled", false)
							} else {
								if (_btn.attr("class") != "off" && (_mobile.val() == "" || _password.val() == "")) {
									_btn.addClass("off").prop("disabled", true)
								}
							}
						}
					}
				}
			}, 500)
		} else {
			o.jalert("绋嶇瓑锛屾鍦ㄧ櫥褰曚腑")
		}
	};
	this.validate = function(obj) {
		var loginbtn = $(obj);
		var _mobile = $("#mobile_" + o.LoginType);
		var m = _mobile.val();
		if (o.LoginType == 0) {
			if (m == "" || m.length != 11 || !rex_mobile.test(m)) {
				o.tips("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙风爜锛�11浣嶆暟锛�", _mobile, true)
			} else {
				o.loginSubmit(loginbtn, "", "", 0, m, "")
			}
		} else {
			if (o.LoginType == 1) {
				var _dynpwd = $("#dynpwd_" + o.LoginType);
				var v = _dynpwd.val();
				if (m == "" || m.length != 11 || !rex_mobile.test(m)) {
					o.tips("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙风爜锛�11浣嶆暟锛�", _mobile, true)
				} else {
					if (v == "" || v.length != 6 || !rex_vcode.test(v)) {
						o.tips("璇疯緭鍏ユ湁鏁堟墜鏈虹煭淇￠獙璇佺爜锛�6浣嶆暟瀛楋級", _dynpwd, true)
					} else {
						o.loginSubmit(loginbtn, "", "", 0, m, v)
					}
				}
			} else {
				if (o.LoginType == 2) {
					var _password = $("#password_" + o.LoginType);
					var p = _password.val();
					if (m == "") {
						o.tips("璇峰～鍐欑櫥褰曡处鍙�", _mobile, true)
					} else {
						if (m.indexOf(" ") != -1) {
							o.tips("璐﹀彿涓嶈兘鍖呭惈绌烘牸", _mobile, true)
						} else {
							if (p == "") {
								o.tips("璇峰～鍐欑櫥褰曞瘑鐮�", _password, true)
							} else {
								if (p.indexOf(" ") != -1) {
									o.tips("瀵嗙爜涓嶈兘鍖呭惈绌烘牸", _password, true)
								} else {
									o.loginSubmit(loginbtn, _mobile, _password, 0, "", "")
								}
							}
						}
					}
				}
			}
		}
	};
	this.loginSubmit = function(btnObj, username, password, uid, MobileVerify, MobileCode) {
		var _moblieverity = $("#mobile_" + o.LoginType);
		var _mobliecode = $("#dynpwd_" + o.LoginType);
		var un = o.LoginType == 2 ? username.val() : "";
		var p = o.LoginType == 2 ? password.val() : "";
		var _btn = btnObj;
		var _oldBtnTxt = _btn.val();
		var _oldBtnClick = _btn.attr("onclick");
		if (o.isLogin == 0) {
			_btn.attr("onclick", "");
			glb.ajax(glb.ajaxUrl + "userlogininfo", "json", "username=" + un + "&password=" + p + "&uid=" + uid +
				"&MobileVerify=" + MobileVerify + "&MobileCode=" + MobileCode + "&LoginType=" + o.LoginType + "&RegDeviceType=2",
				function() {
					_btn.addClass("close").val("鐧诲綍涓�...").prop("disabled", true);
					o.isLogin == 1
				},
				function(data) {
					var d = eval(data);
					o.isLogin == 0;
					if (d.status == 1) {
						o.isLogin == 1;
						_btn.val("鐧诲綍鎴愬姛锛屾鍦ㄨ烦杞�");
						location.href = $("#reurl").val()
					} else {
						if (d.status == 5) {
							o.tips("鎶辨瓑锛岀郴缁熸娴嬪埌鎮ㄦ湁涓ラ噸杩濊鎿嶄綔琛屼负锛屽凡琚姝㈡搷浣�", username, false)
						} else {
							if (d.status == 6) {
								if (o.isSubmit == 1) {
									_btn.removeClass("close").attr("onclick", _oldBtnClick).val(_oldBtnTxt).prop("disabled", false);
									new sms().init().bindMobile("", d.roleID, function(m, v) {
										glb.ajax(glb.ajaxUrl + "bindmobile", "json", "mobile=" + m + "&vcode=" + v + "&uid=" + d.UID, function() {
											o.isSubmit = 0
										}, function(data) {
											var md = eval(data);
											o.isSubmit = 1;
											switch (md.status) {
												case 1:
													$.jfnclose();
													$.jsuccess("缁戝畾鎴愬姛", "auto", null, null);
													o.loginSubmit(btnObj, username, password, d.UID, "", "");
													break;
												case 2:
													o.jalert("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙风爜锛�11浣嶆暟锛�");
													break;
												case 3:
													$("#clt_mobliecode").val("");
													o.jalert("璇疯緭鍏ユ湁鏁堟墜鏈虹煭淇￠獙璇佺爜锛�6浣嶆暟瀛楋級");
													break;
												case 4:
													$("#clt_mobliecode").val("");
													o.jalert("鐭俊楠岃瘉鐮佹棤鏁堬紝璇烽噸鏂板彂閫侀獙璇佺爜鍒版墜鏈�");
													break;
												case 5:
													$("#clt_mobliecode").val("");
													o.jalert("鎮ㄦ彁浜ら獙璇佸お棰戠箒浜�");
													break;
												case 6:
													$("#clt_mobliecode").val("");
													o.jalert("缁戝畾澶辫触锛岃鎵嬫満鍙峰凡澶勪簬璐﹀彿缁戝畾鐘舵€佷簡");
													break;
												default:
													o.jalert("鎿嶄綔澶辫触锛岃閲嶆柊鎻愪氦");
													break
											}
										}, function() {
											o.isSubmit = 1;
											o.jalert("鎿嶄綔澶辫触锛岃閲嶆柊鎻愪氦")
										})
									})
								}
							} else {
								if (d.status == 7 || d.status == 8) {
									_btn.removeClass("close").attr("onclick", _oldBtnClick).val(_oldBtnTxt).prop("disabled", false);
									new sms().init().userVerifyLogin(d.status, d.mobile, d.UID, function(m, v) {
										o.loginSubmit(btnObj, username, password, d.UID, m, v)
									})
								} else {
									if (d.status == 17) {
										o.jalert("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙风爜锛�11浣嶆暟锛�")
									} else {
										if (d.status == 18) {
											$("#clt_mobliecode").val("");
											o.jalert("璇疯緭鍏ユ湁鏁堟墜鏈虹煭淇￠獙璇佺爜锛�6浣嶆暟瀛楋級")
										} else {
											if (d.status == 19) {
												$("#clt_mobliecode").val("");
												o.jalert("杈撳叆鐨勯獙璇佺爜閿欒鎴栨棤鏁�")
											} else {
												if (d.status == 20) {
													o.jalert("鎮ㄦ彁浜ら獙璇佸お棰戠箒浜�")
												} else {
													if (d.status == 21) {
														o.jalert("鎵句笉鍒拌鎵嬫満鍙风粦瀹氱殑璐﹀彿")
													} else {
														if (d.status >= 22 && d.status <= 26) {
															_btn.removeClass("close").attr("onclick", _oldBtnClick).val(_oldBtnTxt).prop("disabled", false);
															if (d.status == 22) {
																o.tips("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙风爜锛�11浣嶆暟锛�", _moblieverity, true)
															} else {
																if (d.status == 23) {
																	o.tips("璇疯緭鍏ユ湁鏁堟墜鏈虹煭淇￠獙璇佺爜锛�6浣嶆暟瀛楋級", _mobliecode, true)
																} else {
																	if (d.status == 24) {
																		o.tips("杈撳叆鐨勯獙璇佺爜閿欒鎴栨棤鏁�", _mobliecode, true);
																		_mobliecode.val("")
																	} else {
																		if (d.status == 25) {
																			o.tips("鎮ㄦ彁浜ょ櫥褰曞お棰戠箒浜�", null, true)
																		} else {
																			if (d.status == 26) {
																				o.tips("鎵句笉鍒拌鎵嬫満鍙风粦瀹氱殑璐﹀彿", _moblieverity, true)
																			} else {
																				o.tips("绯荤粺绻佸繖鐧诲綍澶辫触,璇峰啀娆＄櫥褰�", _moblieverity, true)
																			}
																		}
																	}
																}
															}
														} else {
															if (d.status == 1001 || d.status == 1002) {
																var _regurl = d.status == 1001 ? "/reg/drreg.html" : "/reg/userreg.html";
																location.href = _regurl + "?m=" + username.val() + "&v=" + d.loginReason
															} else {
																_btn.removeClass("close").attr("onclick", _oldBtnClick).val(_oldBtnTxt).prop("disabled", false);
																if (d.status == 0) {
																	o.tips("璐﹀彿鎴栧瘑鐮侀敊璇�&nbsp;&nbsp;<a href='/reg/findpwd.html' style='color:red'>鈫掔偣鍑绘壘鍥炶处鍙峰瘑鐮�</a>",
																		username, false)
																} else {
																	if (d.status == 2) {
																		o.tips(
																			"鎮ㄤ粖澶╁凡澶氭鐧诲綍澶辫触锛岃鏄庡ぉ鍐嶅皾璇曠櫥褰�!<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href='/reg/findpwd.html' style='color:red'>鈫掔偣鍑绘壘鍥炶处鍙峰瘑鐮�,鍗冲彲閲嶆柊鐧诲綍</a>",
																			username, false)
																	} else {
																		if (d.status == 3) {
																			o.tips("鎶辨瓑锛岃甯愬彿宸叉敞閿€锛�<br />鍘熷洜锛�" + d.loginReason, username, false)
																		} else {
																			if (d.status == 4) {
																				o.tips("璐﹀彿鎴栧瘑鐮侀敊璇�,杩樻湁<em style='font-size:20px;font-style:normal;padding:3px'>" + d.errNum +
																					"</em>娆℃満浼氶噸璇曪紒<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href='/reg/findpwd.html' style='color:red'>鈫掔偣鍑绘壘鍥炶处鍙峰瘑鐮�</a>",
																					username, false)
																			} else {
																				if (d.status == 6) {
																					o.tips("鍒涘缓璐﹀彿澶辫触锛岃閲嶆柊灏濊瘯", username, true)
																				} else {
																					o.tips("绯荤粺绻佸繖鐧诲綍澶辫触,璇峰啀娆＄櫥褰�", username, true)
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				},
				function() {
					o.isLogin == 0;
					_btn.removeClass("close").attr("onclick", _oldBtnClick).val(_oldBtnTxt).prop("disabled", false);
					o.tips("绯荤粺绻佸繖鐧诲綍澶辫触,璇烽噸鏂扮櫥褰�", username, true)
				})
		} else {
			o.jalert("绋嶇瓑锛屾鍦ㄧ櫥褰曚腑")
		}
	};
	this.tips = function(txt, obj, isclose) {
		clearTimeout(o.TimeOutInfo);
		$(".info>span>b").html(txt);
		$(".info>span").fadeIn();
		if (isclose) {
			if (obj != null) {
				obj.focus()
			}
			o.TimeOutInfo = setTimeout(function() {
				$(".info>span").fadeOut()
			}, 30000)
		}
	};
	this.jalert = function(info) {
		$.jalerttimer("鎿嶄綔鎻愮ず", info + "<br /><br />", "650", null, 9)
	};
	this.shortcut = function() {
		location.href = "/sys/ieshortcut.ashx"
	}
}
var lg = null;
$(function() {
	lg = new login().init();
	$(".loginform").bind("keydown", function(B) {
		var A = $(this);
		var D = B || window.event;
		var C = D.keyCode || D.which || D.charCode;
		if (C == 13) {
			A.find(".btn>input").click()
		}
	})
});
